﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Users.aspx.vb" Inherits="Training.Users" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Training - Training:: Manage Group Users</title>
<link rel="Stylesheet" type="text/css" media="screen" href="../css/adminStyle.css" />
</head>
<body>
    <form id="form1" runat="server">
    <div class="ctr">
        <h2>Manage Group Users</h2>
        
        <div style="width:750px;text-align:left;margin:0 auto;" class="text">
            <p>Select a group to filter users: 
                <asp:DropDownList ID="ddlGroups" runat="server" DataSourceID="dsGroups" 
                    DataTextField="GroupName" DataValueField="GroupID" CssClass="formfield" 
                    AutoPostBack="true">
                </asp:DropDownList>
            </p>
            
            <p>Search* <!--by Email-->: 
                <asp:TextBox ID="tbUserSearch" CssClass="formfield" Width="120px" 
                    runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="rfSearch"
                        runat="server" ErrorMessage="required" 
                    ControlToValidate="tbUserSearch" CssClass="small" Display="Dynamic"></asp:RequiredFieldValidator> &nbsp; 
                <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="button" /><br />
                <span class="small">(* by First Name, Company Name or Email. Partial names are valid)</span></p>
            
            <p><asp:Label ID="lblMsg" runat="server" Text="" CssClass="Alert"></asp:Label></p>
            
            <asp:GridView ID="gvUsers" runat="server" AllowPaging="True" 
                AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="UserID" 
                DataSourceID="dsUsers" Width="100%">
                <RowStyle CssClass="row1" />
                <EmptyDataRowStyle CssClass="row1" />
                <Columns>
                    <asp:BoundField DataField="UserID" HeaderText="User ID" InsertVisible="False" 
                        ReadOnly="True" SortExpression="UserID">
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="UserName" HeaderText="User Name" ReadOnly="True" 
                        SortExpression="UserName">
                    <HeaderStyle HorizontalAlign="Left" />
                    <ItemStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="CompanyName" HeaderText="Company Name" 
                        SortExpression="CompanyName">
                    <HeaderStyle HorizontalAlign="Left" />
                    <ItemStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email">
                    <HeaderStyle HorizontalAlign="Left" />
                    <ItemStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:CheckBoxField DataField="Active" HeaderText="Active" 
                        SortExpression="Active">
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                    </asp:CheckBoxField>
                    <asp:BoundField DataField="CreatedDate" HeaderText="Created Date" 
                        SortExpression="CreatedDate">
                    <HeaderStyle HorizontalAlign="Left" />
                    <ItemStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:HyperLinkField DataNavigateUrlFields="UserID,UserName" 
                        DataNavigateUrlFormatString="DeleteGroupUser.aspx?uid={0}&amp;unm={1}" HeaderText="Delete" 
                        Text="delete">
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                    </asp:HyperLinkField>
                    <asp:HyperLinkField DataNavigateUrlFields="UserID,UserName" 
                        DataNavigateUrlFormatString="EditGroupUser.aspx?uid={0}&amp;unm={1}" HeaderText="Edit User" 
                        Text="edit">
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                    </asp:HyperLinkField>
                    <asp:HyperLinkField DataNavigateUrlFields="UserID,UserName" 
                        DataNavigateUrlFormatString="ViewUserResults.aspx?uid={0}&amp;unm={1}" HeaderText="Results" 
                        Text="view">
                    <HeaderStyle HorizontalAlign="Center" />
                    <ItemStyle HorizontalAlign="Center" />
                    </asp:HyperLinkField>
                </Columns>
                <PagerStyle CssClass="small" />
                <HeaderStyle CssClass="rowHead" ForeColor="White" />
                <AlternatingRowStyle CssClass="row2" />
            </asp:GridView>
        </div>
        
        <br />
        <p><a href="Default.aspx">Admin Main</a></p>
    </div>
    <!-- data sources -->
    
    <asp:SqlDataSource ID="dsGroups" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Conn %>" 
        SelectCommand="SELECT [GroupID], [GroupName] FROM [Groups] ORDER BY [GroupName]"></asp:SqlDataSource>
    
    <asp:SqlDataSource ID="dsUsers" runat="server" 
        ConnectionString="<%$ ConnectionStrings:Conn %>" 
        SelectCommand="proc_GetUsersByGroupID" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlGroups" DefaultValue="1" Name="GroupID" 
                PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    
    </form>
</body>
</html>
